package com.fireXXX.job.analysis.crawler.common.job;

import com.fireXXX.job.analysis.crawler.boss.constant.CityTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.TechnicalTypeEnum;
import com.fireXXX.job.analysis.crawler.common.Page;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JobTask implements Runnable {

    private JobCrawler crawler;
    private CityTypeEnum city;
    private TechnicalTypeEnum tech;
    private Page page;

    private int sleep = 5000;

    public JobTask(JobCrawler crawler, CityTypeEnum city, TechnicalTypeEnum tech, Page page) {
        this.crawler = crawler;
        this.city = city;
        this.tech = tech;
        this.page = page;
    }

    @SneakyThrows
    @Override
    public void run() {
//        try {
            crawler.crawl(city, tech, page);

            Thread.sleep(sleep);
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error(String.format("crawl city(%s) tech(%s), err(%s)", city, tech.getText(), ExceptionUtil.getFirstNonNullMessage(e)));
//        }
    }
}
